package com.mv.springmvc.aspect;


import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.mv.spring.aop.After;
import com.mv.spring.aop.Aspect;
import com.mv.spring.aop.Before;
import com.mv.spring.aop.Pointcut;
import com.mv.spring.bean.Component;
import com.mv.springmvc.controller.UserController;

@Aspect
@Component
public class LogAspect {
    private static final Logger log = LoggerFactory.getLogger(UserController.class);
    // 定义切点，spring的实现中，
    // 此注解可以使用表达式 execution() 通配符匹配切点，
    // 简单起见，我们先实现明确到方法的切点  
    // 注意 切点方法必须与切点方法名称一致
    @Pointcut("com.mv.springmvc.service.impl.UserServiceImpl.list()")
    public void list() {
    	log.error("##############methodUserListCutPoint");
    }

    @Before("list()")
    public void singAndDance() {
    	log.error("##############before UserServiceImpl.list");
    }

    @After("list()")
    public void basketball() {
    	log.error("##############after UserServiceImpl.list()");
    }

    /*// @Around 是环绕通知，简单起见，我们选择实现 @Before 和 @After
    @Around("execution(* com.caozhihu.demo..*(..))")
    public Object rapPoint(ProceedingJoinPoint joinPoint) throws Throwable {
        // 在 rap 之前要先唱、跳
        System.out.println("prepare to :" + joinPoint.getSignature().getName());
        System.out.println("singing!");
        Object object = joinPoint.proceed();
        // 在 rap 之后要篮球
        System.out.println("basketball!");
        return object;
    }*/

}
